from sentence_transformers import SentenceTransformer

sentences_1 = ["样例数据-1", "样例数据-2"]
sentences_2 = ["样例数据-3", "样例数据-4"]
model = SentenceTransformer('./data/BAAI/bge-small-zh')
embeddings_1 = model.encode(sentences_1, normalize_embeddings=True)
embeddings_2 = model.encode(sentences_2, normalize_embeddings=True)
print(embeddings_1.shape)  # (2, 512) ==> (batch_size,embedding_dims)
print(embeddings_2.shape)  # (2, 512)
similarity = embeddings_1 @ embeddings_2.T  # 相似度得分
print(similarity) # 此处可以求平均值,为相似度得分(得分在[0~1] 越接近1证明越相似,越接近0证明越不相似)
